<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
</head>
<body>
<form>
    <div>用户名：  <input type="text" id="studentName"></div>
    <div>密码：  <input type="password" id="password"></div>
    <div><input type="button" value="登录" id="loginBtn"></div>
    <a href="forgetPage.html">忘记密码</a>
</form>
</body>
</html>
<!-- 通过cdn加载 jQuery，需要联网-->
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script>
    $("#loginBtn").click(function (){
        //获取用户名和密码，并构建json对象
        var data = {"studentName":$("#studentName").val(),
            "password":$("#password").val()
        };

        //发起ajax请求
        $.ajax({
            method:"post",
            url:"student?action=login",
            data:data,
            type:"json",
            success:function (result){
                console.log(result);
                if (result.code == 20001){
                    alert(result.msg);
                    location.href = "main.html";
                }else{
                    alert(result.msg);
                }
            }
        });
    });

</script>